package com.zdy.widget;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by zdy on 2016/9/18.
 */
public class ToastUtil {
    public static void showToastShort(Context context, String text) {
        if (context == null) {
            return;
        }
        View layout = View.inflate(context, R.layout.layout_toast, null);
        TextView t = (TextView) layout.findViewById(R.id.text);
        t.setText(text);
        Toast toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.setView(layout);
        toast.show();
    }
}
